package com.hulk.dryad.manage.framework.websocket.client.config;


import com.hulk.dryad.manage.framework.rediscache.RedisTemplateConfiguration;
import com.hulk.dryad.manage.framework.websocket.client.core.WsClient;
import com.hulk.dryad.manage.framework.websocket.client.support.RedisWsClientImpl;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * redis websocket 客户端配置
 *
 * @author
 */
@Configuration
@ConditionalOnBean(WebSocketClientConfiguration.class)
@AutoConfigureAfter({WebSocketClientConfiguration.class, RedisTemplateConfiguration.class})
@ConditionalOnProperty(
	name = "enabled",
	prefix = WebSocketClientClusterProperties.PREFIX,
	havingValue = "true",
	matchIfMissing = true
)
public class RedisWsClientConfiguration {

	@Bean
	public WsClient wsClient(RedisTemplate redisTemplate,
							 WebSocketClientClusterProperties properties) {
		RedisWsClientImpl impl = new RedisWsClientImpl(redisTemplate, properties);
		return impl;
	}

}
